package com.cham.danmu.controller;

import com.cham.danmu.dto.DanmuShootAndCollectDTO;
import com.cham.danmu.service.DanmuService;
import com.cham.enums.ChamSysCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author Howl-Xu
 * @version 1.0.0
 * @Description: 请描述一下这个类文件吧
 * @createTime 2020年03月31日 11:47:00
 */
@Controller
@RequestMapping("/danmuController")
public class DanmuController {

    @Autowired
    private DanmuService danmuService;
    @PostMapping("/danmuShoot")
    @ResponseBody
    public ChamSysCodeEnum danmuShoot(@RequestBody DanmuShootAndCollectDTO danmuShootAndCollectDTO){
        danmuShootAndCollectDTO.setDanmuCreateDate(new Date());
        danmuService.danmuShoot(danmuShootAndCollectDTO);
        return ChamSysCodeEnum.DANMU_SHOOT_SUCCESS;
    }

    /**
     * 弹幕填充方法
     * @param danmuCollectDTO
     * @return
     */
    @PostMapping("/danmuCollect")
    @ResponseBody
    public List<DanmuShootAndCollectDTO> danmuCollect(@RequestBody DanmuShootAndCollectDTO danmuCollectDTO){
        List<DanmuShootAndCollectDTO> danmuList = null;
        danmuList = danmuService.danmuCollect(danmuCollectDTO);
        //danmuService.danmuShoot(danmuShootDTO);
        return danmuList;
    }

    /**
     * 弹幕填充方法
     * @param videoId
     * @return
     */
    @GetMapping("/getTop1000DanmuByVideoId")
    @ResponseBody
    public List<DanmuShootAndCollectDTO> getTop1000DanmuByVideoId(int videoId){
        return danmuService.getTop1000DanmuByVideoId(videoId);
    }


    @GetMapping("/getDanmuTotalByVideoId")
    @ResponseBody
    public int getDanmuTotalByVideoId(int videoId){
        return danmuService.getDanmuTotalByVideoId(videoId);
    }

}
